package com.arpa.wms.mapper;

import com.arpa.wms.domain.dto.InboundItemDTO;
import com.arpa.wms.domain.entity.InboundItem;
import com.arpa.wms.domain.vo.InboundItemVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 入库单明细 Mapper 接口
 * </p>
 *
 * @author LEO
 * @since 2020-08-04
 */
public interface InboundItemMapper extends BaseMapper<InboundItem> {

    /**
     * 查询列表
     * @param inboundItemDTO
     * @return
     */
    List<InboundItemVO> queryList(InboundItemDTO inboundItemDTO);

    /**
     * 查询合计,包含总数
     * @param inboundItemDTO
     * @return
     */
    InboundItemVO queryListSum(InboundItemDTO inboundItemDTO);

    /**
     * 更新入库明细的存货日期、批号
     * @param putawayCode
     * @return
     */
    @Update("update wms_inbound_item wii, wms_putaway_register wpr " +
            "set wii.lot = wpr.lot, wii.gmt_stock = wpr.gmt_stock " +
            "where wii.putaway_register_code = wpr.code and wpr.putaway_code = #{putawayCode} and wii.group_code = #{groupCode}")
    int updateInventoryInfoByPutawayCode(@Param("putawayCode") String putawayCode, @Param("groupCode") String groupCode);
    /**
     * 获取入库明细详细信息，
     * 用于零散合同修改、启用时使用
     *
     * @param warehouseCode 仓库标识
     * @param goodsCode     商品标识
     * @param receiveLot    收货批号
     * @return
     */
    Map<String, Object> getItemInfo(@Param("warehouseCode") String warehouseCode, @Param("goodsCode") String goodsCode, @Param("receiveLot") String receiveLot, @Param("groupCode") String groupCode);

    /**
     * 执行原生sql
     * @param sql
     */
    void execSql(@Param("sql") String sql);

    /**
     * 查询列表
     * @return
     */
    List<InboundItemVO> queryInboundGoodsSortQuantity();
}
